#include<stdio.h>
#include<math.h>
int main()
{
	int x;
	scanf("%d", &x);
	int y;
	if(x>=3)
	y=3*x+4;
	
	else if(x>=-2)
	y=5-abs(3*x+2);
	
	else
	y=7-2*x;
	
	printf("%d", y);
	
	return 0;
}
